package com.songcha.library_business

import android.app.Application
import android.content.Context
import android.graphics.Color
import com.alibaba.android.arouter.launcher.ARouter
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.MaterialHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.scwang.smart.refresh.layout.api.RefreshFooter
import com.scwang.smart.refresh.layout.api.RefreshHeader
import com.scwang.smart.refresh.layout.api.RefreshLayout
import com.scwang.smart.refresh.layout.listener.DefaultRefreshFooterCreator
import com.scwang.smart.refresh.layout.listener.DefaultRefreshHeaderCreator
import com.songcha.library_business.api.ApiManager
import com.songcha.library_business.config.NetworkConfig
import com.songcha.library_business.helper.SmartRefreshHelper
import com.songcha.library_business.helper.WxHelper
import com.songcha.library_business.provider.IApplicationInitProvider
import com.songcha.library_business.proxy.personal_recommend.PersonalRecommendManager
import com.songcha.library_business.proxy.teenager.TeenagerManager
import com.songcha.library_business.proxy.userinfo.UserInfoManager
import com.songcha.library_common.BuildConfig
import com.songcha.library_common.LibraryCommon
import com.songcha.library_database_douyue.LibraryDatabaseDouyueApplication


class LibraryBusinessApplication {
    companion object{
        private lateinit var mContext: Context

        @JvmStatic
        fun getContext():Context{
            return mContext
        }

        init {
           SmartRefreshHelper.init()
        }

        @JvmStatic
        fun init(application: Application){
            mContext=application

            //LibraryCommon.init(mContext,BuildConfig.DEBUG)
            //ModuleReaderApplication.init(mContext)
            //LibraryDatabaseSakuraApplication.init(mContext)
            LibraryCommon.init(application)

            if(BuildConfig.DEBUG){
                ARouter.openLog()
                ARouter.openDebug()
            }
            ARouter.init(application)

            //module init
            ARouter.getInstance().build("/main/AppInitImpl").navigation()?.let {
                it as IApplicationInitProvider
                it.initApplication(application)
            }

            ARouter.getInstance().build("/bookreader/AppInitImpl").navigation()?.let {
                it as IApplicationInitProvider
                it.initApplication(application)
            }

            ARouter.getInstance().build("/splash/AppInitImpl").navigation()?.let {
                it as IApplicationInitProvider
                it.initApplication(application)
            }

            ARouter.getInstance().build("/mine/AppInitImpl").navigation()?.let {
                it as IApplicationInitProvider
                it.initApplication(application)
            }

            //release force modify to release domain
            if(!BuildConfig.DEBUG) NetworkConfig.IS_RELEASE=true

            UserInfoManager.init()
            TeenagerManager.init()
            PersonalRecommendManager.init()

            //database init
            LibraryDatabaseDouyueApplication.init(application)


        }
    }

}